import request from '@/config/axios'
import type { GroupsData } from './types'

export const getGroupsListApi = (params: any): Promise<IResponse> => {
    const queryParams = params.queryParams ? params.queryParams : {}
    if (params.queryParams) {
        delete params.queryParams
    }
    Object.assign(params, queryParams)
    return request.get({url: '/balance/group/page', params})
}

export const saveOrUpdateGroupsApi = (data: Partial<GroupsData>, isUpdate = false): Promise<IResponse> => {
    if(isUpdate) {
        return request.post({url: '/balance/group/edit', data})
    }else {
        return request.post({url: '/balance/group/save', data})
    }
}

export const getGroupsDetailApi = (data: Partial<GroupsData>): Promise<IResponse<GroupsData>> => {
    return request.get({url: '/balance/group/detail', params: data})
}

export const delGroupsListApi = (data: Partial<GroupsData>[]): Promise<IResponse> => {
    return request.post({url: '/balance/group/delete', data})
}
